﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using Atom.Entity;
using System.Data;
using Atom.Utility.Data;

namespace Atom.DAL
{
    public class TestDAL:BaseDAL
    {

        /// ---------------------------------------------------------------------
        /// <summary>
        /// 插入表PFC_SysLog
        /// </summary>
        /// <param name="entity">日志表实体</param>
        /// <param name="tran">事务</param>
        /// <returns>sql执行结果</returns>
        ///  <history>[兆尹科技(洪勇勇)] 2010/07/27 Created</history>
        /// ---------------------------------------------------------------------
        public SqlExecuteResult Insert(TestEntity entity)
        {
            try
            {
               
                string sql = @"INSERT INTO [test](
                           ,[Name]
                           ,[decription])
                            VALUES(@ID,@Name,@decription)";

                DbCommand cmd = DataAccess.GetSqlStringCommand(sql);

                DataAccess.AddInParameter(cmd, "Name", DbType.String, entity.Name);
                DataAccess.AddInParameter(cmd, "decription", DbType.String, entity.decription);
              

                return base.ExecuteCommand(cmd, null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public List<TestEntity> GetAll()
        {
            try
            {
               
                string sql = @"select * from  [test]";

                DbCommand cmd = DataAccess.GetSqlStringCommand(sql);

                return DataAccessExtensive.ExecuteListEntity<TestEntity>(this.DataAccess
                , cmd
                , SetEntityConcern);
              

                
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }



        private void SetEntityConcern(TestEntity entity, IDataReader dr)
        {
            SetEntityUti(entity, "Name", "Name", dr);
            SetEntityUti(entity, "decription", "decription", dr);
         
        }

        


    }
}
